<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数类型</title>
    <script>
        function f1() {
            console.log("正在执行f1")
            let s = test();
            console.log(s)
            console.log(typeof s);
        }

        function test() {
            console.log("正在执行test")
            return "Hello World";
        }

        function f2(i, j, a, b, c) {
            console.log(i + j);
            return i + j;
        }

        function f3() {
            // console.log(arguments)
            for (let i = 0; i < arguments.length; i++) {
                console.log(arguments[i])
            }
            let i = arguments[0];
            let j = arguments[1];
            let a = arguments[2];
            let b = arguments[3];
            let c = arguments[4];
            let d = arguments[5];
            console.log("i=" + i + ",j=" + j + ",a=" + a + ",b=" + b + ",c=" + c + ",d=" + d)
        }

        function f4() {
            // 当函数带有括号时表示调用该函数
            // 且将函数的返回值赋值给对应变量
            let a = test();
            console.log(typeof a);
            // 当函数没有括号,表示将函数整体作为一个变量的值
            // 此时的函数没有被执行
            let b = test;
            console.log(typeof b);
            console.log(b)
            // alert(b)
            b();
        }

        function f5() {
            let a = function () {
                console.log("正在执行匿名函数");
            }
            console.log(typeof a)
            a();
        }

        function f6() {
            let a = () => "Hello World";
            console.log(typeof a)
            let b = (a, b) => {
                console.log("正在执行求和功能");
                return a + b;
            }
            console.log(typeof b)
            console.log(b(2,3))
        }
    </script>
</head>
<body>
<button onclick="f1()">测试</button>
<br>
<button onclick="f2(1,2)">求和</button>
<br>
<button onclick="f3(1,2,5)">测试</button>
<br>
<button onclick="f4()">定义方式一</button>
<br>
<button onclick="f5()">定义方式二</button>
<br>
<button onclick="f6()">定义方式三</button>
<br>
</body>
</html>